
jQuery(document).ready(function(){

  // News Ticker
  var ticker = function()
  {
    setTimeout(function(){
      $('#ticker li:first').animate( {marginTop: '-28px'}, 800, function()
      {
        $(this).detach().appendTo('ul#ticker').removeAttr('style');  
      });
      ticker();
    }, 4000);
  };
  ticker();

  // Tabbed News
  $(".tab_content").hide(); //Hide all content
  $("ul.tabs li:first").addClass("active").show(); //Activate first tab
  $(".tab_content:first").show(); //Show first tab content
  
  $("ul.tabs li").click(function() {   //On Click Event
    $("ul.tabs li").removeClass("active"); //Remove any "active" class
    $(this).addClass("active"); //Add "active" class to selected tab
    $(".tab_content").hide(); //Hide all tab content
    var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
    $(activeTab).fadeIn(); //Fade in the active content
    return false;
  });  
            
 
});

var home = window.location.href; 

// remove tags
function stripHtmlTags(s,max){
s=s.replace(/<br.*?>/ig, ' ');
return s.replace(/<.*?>/ig, '').split(/\s+/).slice(0,max-1).join(' ')
}
//get RSS FEED
function news(json) {

document.write('<ul id="ticker">');

img = new Array();
maxpost=json.feed.entry.length;
     
for (var i = 0; i < maxpost; i++) {

  //Get Entry
  var entry = json.feed.entry[i];
  var posttitle = entry.title.$t;
  var pcm ;
  var posturl;
  
  
  //Get link Url
  for (var k = 0; k < entry.link.length; k++) {
    if (entry.link[k].rel == 'alternate') {
    posturl = entry.link[k].href;
      break;
    }
  }  
  
  //Get Label
  var plabel = new Array();
  var cate = entry.category;
  if(cate) {
    for (var k = 0; k < entry.category.length; k++) {
      plabel[k] = ' <a class="label-link" href="http://'+home.split('/')[2]+'/search/label/'+entry.category[k].term+'">'+entry.category[k].term+'</a> ';
    }
  }
  else {plabel = home.split('/')[2].replace(/www/gi,"");}
  
  //Get body (Post)
  var postdate = entry.published.$t;
  var day = postdate.split("-")[2].substring(0,2);
  var m = postdate.split("-")[1];
  var y = postdate.split("-")[0];
  postDay = day+ "." + m + "." + y ;
  
    //Get Comments
  if ("thr$total" in entry) {pcm=entry.thr$total.$t;}
  else {pcm="none";}
  
  
  //Data show for view.

  var td_list = '<li><strong>'+plabel[0]+': </strong><a rel="bookmark" title="'+posttitle+'" href="'+posturl+'">'+posttitle.split('-')[0]+'</a><span class="meta-date"> '+postDay+'</span><span class="meta-sep"> | </span><span class="meta-comments"><a title="Comment on '+posttitle+'" href="'+posturl+'#disqus_thread"></a></span></li>';
  
    //Check view --
  document.write(td_list);
    
  }  //End for
  document.write('</ul>');
}  //End function

